import request from '@/utils/request'

// 查询小区列表
export function listDistrict(query) {
  return request({
    url: '/community/district/list',
    method: 'get',
    params: query
  })
}
export function listDistricts(query) {
  return request({
    url: '/community/district/listVo',
    method: 'get',
    params: query
  })
}

// 查询小区详细
export function getDistrict(id) {
  return request({
    url: '/community/district/' + id,
    method: 'get'
  })
}

// 新增小区
export function addDistrict(data) {
  return request({
    url: '/community/district',
    method: 'post',
    data: data
  })
}

// 修改小区
export function updateDistrict(data) {
  return request({
    url: '/community/district',
    method: 'put',
    data: data
  })
}

// 删除小区
export function delDistrict(id) {
  return request({
    url: '/community/district/' + id,
    method: 'delete'
  })
}
// 获取小区下拉列表statistics
export function getDistrictSelect() {
  return request({
    url: '/community/district/districtList',
    method: 'get'
  })
}
// 获取统计数量
export function getDistrictCount(id) {
  return request({
    url: '/community/statistics/districtCount/'+id,
    method: 'get'
  })
}
// 导入小区
export function handleImportDistrict(file) {
  const formData = new FormData();
  formData.append('file', file); // 将文件添加到 FormData 对象中

  return request({
    url: '/community/district/import',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data' // 设置正确的 Content-Type
    }
  });
}
// 获取统计数量
export function populationCount() {
  return request({
    url: '/community/statistics/populationCount',
    method: 'get'
  })
}
export function estateCount() {
  return request({
    url: '/community/statistics/estateCount',
    method: 'get'
  })
}

//查询辖区下的所有小区
export function getDistrictByAreaId(id) {
  return request({
    url: '/community/district/getDistrictByAreaId/'+id,
    method: 'get'
  })
}



